
#include <iostream>
#include <iomanip>
#include <memory>
 
struct Vec3
{
    int x, y, z;
 
    // following constructor is no longer needed since C++20
    Vec3(int xd = 0, int yd = 0, int zd = 0) noexcept { 
        x = xd;
        y = yd;
        z = zd;
    }

    Vec3(Vec3*& ptr) {

        if (ptr == nullptr)
            std::cout << "find it"  << std::endl;
        x = ptr->x;
        y = ptr->y;
        z = ptr->z;
    }
 
    friend std::ostream& operator<<(std::ostream& os, const Vec3& v) {
        return os << "{ x= " << v.x  << ", y=" << v.y << ", z=" << v.z << " }";
    }
};
 
int main()
{
    // Use the default constructor.
    //std::unique_ptr<Vec3> v1 = std::make_unique<Vec3>();
    // Use the constructor that matches these arguments
    
    //Vec3* v1 = new Vec3(1,2,3);
    ///std::unique_ptr<Vec3> v2 = std::make_unique<Vec3>(v1);

    // if (v2.get() == nullptr) 
    //     std::cout << "hel" << std::endl;

    // std::cout << "x " << v2->x << " y " << v2->y << " z "<< v2->z << std::endl;



    // // Create a unique_ptr to an array of 5 elements
    // std::unique_ptr<Vec3[]> v3 = std::make_unique<Vec3[]>(5);
 
    // std::cout << "make_unique<Vec3>():      " << *v1 << '\n'
    //           << "make_unique<Vec3>(0,1,2): " << *v2 << '\n'
    //           << "make_unique<Vec3[]>(5):   ";
    // for (int i = 0; i < 5; i++) {
    //     std::cout << std::setw(i ? 30 : 0) << v3[i] << '\n';
    // }
}